package pers.whj.util.tree;

public interface BinaryTree<T> extends Tree<T> {
    T leftChild(T parent);

    T rightChild(T parent);

    boolean insertLeft(T parent, T data);

    boolean insertRight(T parent, T data);

    boolean removeLeft(T parent);

    boolean removeRight(T parent);

    void preOrder(Visit<T> visit);

    void preOrder(VisitExpand<T> visit);

    void inOrder(Visit<T> visit);

    void inOrder(VisitExpand<T> visit);

    void postOrder(Visit<T> visit);

    void postOrder(VisitExpand<T> visit);

    void levelOrder(Visit<T> visit);

    void levelOrder(VisitExpand<T> visit);

    T[] toArrayWithPreOrder(Class<T> type);

    T[] toArrayWithInOrder(Class<T> type);

    T[] toArrayWithPostOrder(Class<T> type);

    T[] toArrayWithLevelOrder(Class<T> type);

    boolean buildCompleteBinaryTree(T[] data);

    // assert that there are no identical elements
    boolean buildByPreOrderAndInOrder(T[] preOrder, T[] inOrder);

    // assert that there are no identical elements
    boolean buildByPostOrderAndInOrder(T[] postOrder, T[] inOrder);

    // assert that there are no identical elements
    boolean buildByLevelOrderAndInOrder(T[] levelOrder, T[] inOrder);

    String convertToGenList() throws Exception;
}